/**
 * 
 */
package neptune.web.server;

import java.io.OutputStream;
import java.io.PrintStream;

/**
 * @author Roberto Bifulco [RobertoBifulco.it] [info@robertoBifulco.it]
 *
 */
public class Debug {

	private static boolean debug = false;
	private static PrintStream out = System.out;
	
	public static void setDebug(boolean debug){
		Debug.debug = debug;
	}
	
	public static void setOutputStream(OutputStream out){
		Debug.out = new PrintStream(out);
	}
	
	public static void add(String message){
		if(debug)
			out.println(message);
	}
	
	public static void add(Throwable e){
		if(debug){
			out.println(e.getMessage());
		}
	}
	
	public static void printTrace(Throwable e){
		if(debug)
			e.printStackTrace(out);
	}
}
